<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>键盘事件</title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}
		</style>
	</head>
	<body>
		<div class="wrapper" style="
		width:230px;height:230px ;
		background-color: orange;
		margin-top:50px;margin-left:10px;">

		</div>
		<script type="text/javascript">
			//var wrapper = document.getElementsByClassName("wrapper")[0];

			document.onkeypress = function(e) { /* 所有字符类按键都能监听*/
				console.log("onkeypress3");
				console.log(String.fromCharCode(e.key) );
				console.log(String.fromCharCode(e.charCode) );
				console.log(String.fromCharCode(e.which) );
			}
			document.onkeydown = function(e) {
				console.log("onkeydown1"); /* 基本所有键盘按键都能监听*/
				console.log(String.fromCharCode(e.key) );
				console.log(String.fromCharCode(e.charCode) );
				console.log(String.fromCharCode(e.which) );
			}
			document.onkeyup = function() {
				console.log("onkeyup2");

			}
		</script>
	</body>
</html>
